/*     */ package com.zimbra.cs.account.ldap.upgrade;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.util.StringUtil;
/*     */ import com.zimbra.cs.account.Config;
/*     */ import com.zimbra.cs.account.Entry;
/*     */ import com.zimbra.cs.account.Server;
/*     */ import com.zimbra.cs.account.accesscontrol.TargetType;
/*     */ import com.zimbra.cs.account.ldap.LdapProv;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.Set;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class BUG_58514
/*     */   extends UpgradeOp
/*     */ {
/*     */   void doUpgrade()
/*     */     throws ServiceException
/*     */   {
/*  37 */     upgradeZimbraGalLdapAttrMap();
/*  38 */     upgradeZimbraContactHiddenAttributes();
/*     */   }
/*     */   
/*     */   private void upgradeZimbraGalLdapAttrMap() throws ServiceException {
/*  42 */     String attrName = "zimbraGalLdapAttrMap";
/*     */     
/*  44 */     String valueToRemove = "binary zimbraPrefMailSMIMECertificate,userCertificate,userSMIMECertificate=SMIMECertificate";
/*     */     
/*  46 */     String[] valuesToAdd = { "(certificate) userCertificate=userCertificate", "(binary) userSMIMECertificate=userSMIMECertificate" };
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*  51 */     Config config = this.prov.getConfig();
/*     */     
/*  53 */     Map<String, Object> attrs = new HashMap();
/*     */     
/*  55 */     Set<String> curValues = config.getMultiAttrSet("zimbraGalLdapAttrMap");
/*  56 */     if (curValues.contains("binary zimbraPrefMailSMIMECertificate,userCertificate,userSMIMECertificate=SMIMECertificate")) {
/*  57 */       StringUtil.addToMultiMap(attrs, "-zimbraGalLdapAttrMap", "binary zimbraPrefMailSMIMECertificate,userCertificate,userSMIMECertificate=SMIMECertificate");
/*     */     }
/*     */     
/*  60 */     for (String valueToAdd : valuesToAdd) {
/*  61 */       if (!curValues.contains(valueToAdd)) {
/*  62 */         StringUtil.addToMultiMap(attrs, "+zimbraGalLdapAttrMap", valueToAdd);
/*     */       }
/*     */     }
/*     */     
/*  66 */     modifyAttrs(config, attrs);
/*     */   }
/*     */   
/*     */   private void upgradeZimbraContactHiddenAttributes(Entry entry) throws ServiceException {
/*  70 */     String attrName = "zimbraContactHiddenAttributes";
/*  71 */     String SMIMECertificate = "SMIMECertificate";
/*     */     
/*  73 */     String curValue = entry.getAttr("zimbraContactHiddenAttributes", false);
/*     */     
/*  75 */     if ((curValue == null) || (!curValue.contains("SMIMECertificate"))) {
/*  76 */       return;
/*     */     }
/*     */     
/*  79 */     String[] hiddenAttrs = curValue.split(",");
/*     */     
/*  81 */     StringBuilder sb = new StringBuilder();
/*  82 */     boolean first = true;
/*  83 */     for (String hiddenAttr : hiddenAttrs) {
/*  84 */       if (!hiddenAttr.equals("SMIMECertificate")) {
/*  85 */         if (!first) {
/*  86 */           sb.append(",");
/*     */         } else {
/*  88 */           first = false;
/*     */         }
/*  90 */         sb.append(hiddenAttr);
/*     */       }
/*     */     }
/*     */     
/*  94 */     this.printer.println("Upgrading " + TargetType.getTargetType(entry).getPrettyName() + " " + entry.getLabel());
/*  95 */     this.printer.println("    Current value of zimbraContactHiddenAttributes: " + curValue);
/*  96 */     this.printer.println("    New value of zimbraContactHiddenAttributes: " + sb.toString());
/*     */     
/*  98 */     Map<String, Object> attrs = new HashMap();
/*  99 */     attrs.put("zimbraContactHiddenAttributes", sb.toString());
/* 100 */     modifyAttrs(entry, attrs);
/*     */   }
/*     */   
/*     */   private void upgradeZimbraContactHiddenAttributes() throws ServiceException
/*     */   {
/* 105 */     Config config = this.prov.getConfig();
/* 106 */     upgradeZimbraContactHiddenAttributes(config);
/*     */     
/* 108 */     List<Server> servers = this.prov.getAllServers();
/*     */     
/* 110 */     for (Server server : servers) {
/* 111 */       upgradeZimbraContactHiddenAttributes(server);
/*     */     }
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/upgrade/BUG_58514.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */